package com.yanqu.road.server.cmd.house;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.house.HouseProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.HouseModule;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_HOUSE_CHANGE_SKIN, desc = "钱庄变更皮肤")
public class HouseChangeSkinCmd extends AbstractCommand {

	private int bankSkinId;

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		HouseProto.HouseChangeSkinReqMsg reqMsg = HouseProto.HouseChangeSkinReqMsg.parseFrom(packet.getBytes());
		bankSkinId = reqMsg.getSkinId();
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
		ret = player.getModule(HouseModule.class).changeSkin(bankSkinId);
	}

	@Override
	public void sendData(GamePlayer player) {
		HouseProto.HouseChangeSkinRespMsg.Builder respMsg = HouseProto.HouseChangeSkinRespMsg.newBuilder();
		respMsg.setRet(ret);
		player.sendPacket(Protocol.U_HOUSE_CHANGE_SKIN, respMsg);
	}

}
